﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Net.Fan.SmallPig.DataAccess;
using Net.Fan.SmallPig.BusinessRules;

public partial class Workflow_CreateDocStep2 : System.Web.UI.Page
{
    long workflowId;
    protected void Page_Load(object sender, EventArgs e)
    {
        string w = Request.Params["W"];
        long.TryParse(w, out workflowId);
        if (IsPostBack == false)
        {
            LabelWorkflowID.Text = w;
            LabelWorkflowName.Text = WorkflowDA.GetWorkflowName(workflowId);
        }
    }

    protected void LinkButtonSubmit_Click(object sender, EventArgs e)
    {
        long count;
        long.TryParse(TextBoxCount.Text, out count);
        string splanfinish = TextBoxPlanFinish.Text.Trim();
        DateTime? planF = null;
        if (string.IsNullOrEmpty(splanfinish))
        {
        }
        else
        {
            DateTime dt;
            bool b = DateTime.TryParse(splanfinish, out dt);
            if (b)
            {
                planF = dt;
            }
            else
            {

            }
        }

        long jobId = JobBiz.AddNewJob(workflowId, TextBoxSummary.Text.Trim(), TextBoxCustomer.Text.Trim(), count, TextBoxDesc.Text, planF, Page.User.Identity.Name);

        Response.Redirect(string.Format("CreateDocStep3.aspx?J={0}", jobId));
    }
}
